package com.gaotu.demo.transaction.springdata;

import com.gaotu.demo.transaction.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Transactional(value = "jpaTransactionManager")
public interface JpaBasedUserRepository extends JpaRepository<User, Long> {

    User getByUserName(String name);

    Page<User> getByCreateTimeAfter(Date date, Pageable pageable);

    @Query("select u from  User u where u.id in ?1")
    List<User> getByIdIn(List<Long> ids);
}
